import requests
from common.ihrm_login_gettoken import ihrm_login_gettoken
from config import local_host
class IhrmUserApi:
    add_url = local_host + "/api/sys/user"
    user_url = local_host + "/api/sys/user/"
    header = {"Authorization": ihrm_login_gettoken()} #公共的请求头，提取为类属性，定义一次多次引用

    @classmethod
    def ihrm_user_add(cls,add_json):
        resp = requests.post(url=cls.add_url,json=add_json,headers=cls.header)
        return resp

    #修改员工信息
    @classmethod
    def ihrm_user_modify(cls,user_id,edit_json):
        edit_url = cls.user_url + str(user_id)
        resp = requests.put(url=edit_url,json=edit_json,headers=cls.header)
        return resp

    @classmethod
    def ihrm_user_delete(cls,user_id):
        delete_url = cls.user_url + str(user_id)
        resp = requests.delete(url=delete_url,headers=cls.header)
        return resp

    #查询员工
    @classmethod
    def ihrm_user_get(cls,user_id):
        get_url = cls.user_url + str(user_id)
        resp = requests.get(url=get_url,headers=cls.header)
        return resp

    #查询员工管理列表
    @classmethod
    def ihrm_user_list(cls,page=1,size=10):
        list_url = cls.add_url
        params = {"page":page,"size":size}
        resp = requests.get(url=list_url,params=params,headers=cls.header)
        return resp












